/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FormRBeli.java
 *
 * Created on Feb 18, 2011, 10:52:22 PM
 */

package juwita;

import config.DBConnection;
import java.awt.CardLayout;
import java.sql.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.JOptionPane;
import javax.swing.table.TableColumn;

//buat date
import java.util.Date;
import java.text.DateFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Locale;

/**
 *
 * @author Abah
 */
public class FormRBeli extends javax.swing.JInternalFrame {

    private DefaultTableModel DftTabModeReturBeli;
    private DefaultTableModel DftTabModeDetailReturBeli;
    private DefaultTableModel DftTabModeBeli;
    private DefaultTableModel DftTabModeDetailBeli;
    
    java.sql.Connection conn = new DBConnection().connect();

    String sTglRBeli = "";
    int noItem = 0; //buat adddata
    

    /** Creates new form FormRBeli */
    public FormRBeli() {
        initComponents();
        dcTglReturBeli.setDate(getDateTime());

        //gj/btnEdit.setEnabled(false);
        //gj/btnDelete.setEnabled(false);
        tbReturBeli.getTableHeader().setReorderingAllowed(false);
        tbBeli.getTableHeader().setReorderingAllowed(false);
        
        tbDetailBeli.getTableHeader().setReorderingAllowed(false);
        Object[] Baris={"Kode Brg", "Nama Brg", "Bal", "Slop", "Bks"};
        DftTabModeDetailBeli=new DefaultTableModel(null,Baris);
        tbDetailBeli.setModel(DftTabModeDetailBeli);

        tbDetailRetur.getTableHeader().setReorderingAllowed(false);
        Object[] Baris2={"Kode Brg", "Nama Brg", "Bal", "Slop", "Bks"};
        DftTabModeDetailReturBeli=new DefaultTableModel(null,Baris2);
        tbDetailRetur.setModel(DftTabModeDetailReturBeli);
        
        setKdReturBeli();

        tampilReturBeli();        
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pnJudul = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        pnBeli = new javax.swing.JPanel();
        pnBeliAtas = new javax.swing.JPanel();
        dcTglReturBeli = new com.toedter.calendar.JDateChooser();
        txtNmSupplier = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        txtKdBeli = new javax.swing.JTextField();
        btnCariBeli = new javax.swing.JButton();
        txtKdReturBeli = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        txtTglBeli = new javax.swing.JTextField();
        btnNew = new javax.swing.JButton();
        txtKdSupplier = new javax.swing.JTextField();
        pnShow = new javax.swing.JPanel();
        pnDetailBeli = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        spDetailBeli = new javax.swing.JScrollPane();
        tbDetailBeli = new javax.swing.JTable();
        pnDaftarBeli = new javax.swing.JPanel();
        pnCrBeli = new javax.swing.JPanel();
        spBeli = new javax.swing.JScrollPane();
        tbBeli = new javax.swing.JTable();
        pnAtas1 = new javax.swing.JPanel();
        btnShowAllBeli = new javax.swing.JButton();
        txtSrcBeli = new javax.swing.JTextField();
        cbSrcBeli = new javax.swing.JComboBox();
        btnSearchBeli = new javax.swing.JButton();
        infoBeli = new javax.swing.JLabel();
        btnCloseBeli = new javax.swing.JButton();
        pnReturBeli = new javax.swing.JPanel();
        spReturBeli = new javax.swing.JScrollPane();
        tbReturBeli = new javax.swing.JTable();
        pnSearchReturBeli = new javax.swing.JPanel();
        btnReturSearch = new javax.swing.JButton();
        btnReturShowAll = new javax.swing.JButton();
        txtSrcReturBeli = new javax.swing.JTextField();
        cbSrcReturBeli = new javax.swing.JComboBox();
        infoReturBeli = new javax.swing.JLabel();
        btnCloseReturBeli = new javax.swing.JButton();
        pnRetur = new javax.swing.JPanel();
        pnReturAtas = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        btnAddRetur = new javax.swing.JButton();
        txtReturBalRetur = new javax.swing.JTextField();
        txtReturNmBrg = new javax.swing.JTextField();
        txtReturBal = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        txtReturSlop = new javax.swing.JTextField();
        txtReturSlopRetur = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        txtReturBks = new javax.swing.JTextField();
        txtReturBksRetur = new javax.swing.JTextField();
        txtReturKdBrg = new javax.swing.JTextField();
        pnReturBawah = new javax.swing.JPanel();
        spDetailRetur = new javax.swing.JScrollPane();
        tbDetailRetur = new javax.swing.JTable();
        jPanel2 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        btnReturOk = new javax.swing.JButton();
        btnReturCancel = new javax.swing.JButton();

        setBackground(new java.awt.Color(255, 255, 255));
        setClosable(true);
        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setIconifiable(true);
        setMaximizable(true);
        setResizable(true);
        setTitle("Retur Pembelian");
        setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/returbeli.png"))); // NOI18N
        addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
            public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
                formInternalFrameClosing(evt);
            }
            public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
            }
        });

        pnJudul.setBackground(new java.awt.Color(255, 255, 255));
        pnJudul.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204)));
        pnJudul.setPreferredSize(new java.awt.Dimension(487, 50));
        pnJudul.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18));
        jLabel1.setForeground(new java.awt.Color(0, 0, 204));
        jLabel1.setText("Retur Pembelian");
        pnJudul.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 10, -1, -1));

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/returbeli-p.png"))); // NOI18N
        pnJudul.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 0, -1, -1));

        getContentPane().add(pnJudul, java.awt.BorderLayout.PAGE_START);

        pnBeli.setBackground(new java.awt.Color(255, 255, 255));
        pnBeli.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204)));
        pnBeli.setPreferredSize(new java.awt.Dimension(370, 202));
        pnBeli.setLayout(new java.awt.BorderLayout());

        pnBeliAtas.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        pnBeliAtas.setPreferredSize(new java.awt.Dimension(200, 125));
        pnBeliAtas.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        dcTglReturBeli.setDateFormatString("dd/MM/yyyy");
        dcTglReturBeli.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                dcTglReturBeliPropertyChange(evt);
            }
        });
        pnBeliAtas.add(dcTglReturBeli, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 10, 110, 20));

        txtNmSupplier.setEditable(false);
        pnBeliAtas.add(txtNmSupplier, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 80, 190, -1));

        jLabel8.setText("Tanggal");
        pnBeliAtas.add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 100, -1, -1));

        jLabel9.setText("Supplier");
        pnBeliAtas.add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 60, -1, -1));

        jLabel3.setText("Kode Beli");
        pnBeliAtas.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 40, -1, -1));

        txtKdBeli.setEditable(false);
        txtKdBeli.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        pnBeliAtas.add(txtKdBeli, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 40, 100, -1));

        btnCariBeli.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/search.png"))); // NOI18N
        btnCariBeli.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCariBeliActionPerformed(evt);
            }
        });
        pnBeliAtas.add(btnCariBeli, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 40, 30, 20));

        txtKdReturBeli.setEditable(false);
        txtKdReturBeli.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtKdReturBeli.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtKdReturBeliKeyReleased(evt);
            }
        });
        pnBeliAtas.add(txtKdReturBeli, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 10, 90, -1));

        jLabel4.setText("Kode Retur");
        pnBeliAtas.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 11, -1, -1));

        txtTglBeli.setEditable(false);
        pnBeliAtas.add(txtTglBeli, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 100, 100, -1));

        btnNew.setText("New");
        btnNew.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNewActionPerformed(evt);
            }
        });
        pnBeliAtas.add(btnNew, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 10, 70, -1));

        txtKdSupplier.setEditable(false);
        txtKdSupplier.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        pnBeliAtas.add(txtKdSupplier, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 60, 100, -1));

        pnBeli.add(pnBeliAtas, java.awt.BorderLayout.PAGE_START);

        pnShow.setLayout(new java.awt.CardLayout());

        pnDetailBeli.setLayout(new java.awt.BorderLayout());

        jPanel1.setPreferredSize(new java.awt.Dimension(368, 20));

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel5.setForeground(new java.awt.Color(0, 0, 153));
        jLabel5.setText("Detail Pembelian");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel5)
                .addContainerGap(263, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jLabel5)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pnDetailBeli.add(jPanel1, java.awt.BorderLayout.PAGE_START);

        tbDetailBeli.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "Kode Brg", "Nama Barang", "Jumlah"
            }
        ));
        tbDetailBeli.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        tbDetailBeli.setGridColor(new java.awt.Color(51, 153, 255));
        tbDetailBeli.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                tbDetailBeliMousePressed(evt);
            }
        });
        tbDetailBeli.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tbDetailBeliKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tbDetailBeliKeyReleased(evt);
            }
        });
        spDetailBeli.setViewportView(tbDetailBeli);

        pnDetailBeli.add(spDetailBeli, java.awt.BorderLayout.CENTER);

        pnShow.add(pnDetailBeli, "detailbeli");

        pnDaftarBeli.setLayout(new java.awt.BorderLayout());

        pnCrBeli.setBackground(new java.awt.Color(255, 255, 255));
        pnCrBeli.setLayout(new java.awt.BorderLayout());

        tbBeli.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tbBeli.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        tbBeli.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                tbBeliMousePressed(evt);
            }
        });
        tbBeli.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tbBeliKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tbBeliKeyReleased(evt);
            }
        });
        spBeli.setViewportView(tbBeli);

        pnCrBeli.add(spBeli, java.awt.BorderLayout.CENTER);

        pnAtas1.setBackground(new java.awt.Color(255, 255, 255));
        pnAtas1.setPreferredSize(new java.awt.Dimension(410, 70));
        pnAtas1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        btnShowAllBeli.setText("All");
        btnShowAllBeli.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnShowAllBeliActionPerformed(evt);
            }
        });
        pnAtas1.add(btnShowAllBeli, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 10, 70, -1));
        pnAtas1.add(txtSrcBeli, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 50, 220, -1));

        cbSrcBeli.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Kode Beli", "Supplier" }));
        pnAtas1.add(cbSrcBeli, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 30, 100, -1));

        btnSearchBeli.setText("Search");
        btnSearchBeli.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSearchBeliActionPerformed(evt);
            }
        });
        pnAtas1.add(btnSearchBeli, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 40, 70, -1));

        infoBeli.setFont(new java.awt.Font("Tahoma", 1, 12));
        infoBeli.setForeground(new java.awt.Color(0, 0, 204));
        infoBeli.setText("Daftar Pembelian");
        pnAtas1.add(infoBeli, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 10, -1, -1));

        btnCloseBeli.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/close_small.png"))); // NOI18N
        btnCloseBeli.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCloseBeliActionPerformed(evt);
            }
        });
        pnAtas1.add(btnCloseBeli, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 10, 30, 20));

        pnCrBeli.add(pnAtas1, java.awt.BorderLayout.PAGE_START);

        pnDaftarBeli.add(pnCrBeli, java.awt.BorderLayout.CENTER);

        pnShow.add(pnDaftarBeli, "beli");

        pnReturBeli.setLayout(new java.awt.BorderLayout());

        spReturBeli.setAutoscrolls(true);

        tbReturBeli.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tbReturBeli.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        tbReturBeli.setGridColor(new java.awt.Color(0, 0, 255));
        tbReturBeli.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                tbReturBeliMousePressed(evt);
            }
        });
        tbReturBeli.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tbReturBeliKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tbReturBeliKeyReleased(evt);
            }
        });
        spReturBeli.setViewportView(tbReturBeli);

        pnReturBeli.add(spReturBeli, java.awt.BorderLayout.CENTER);

        pnSearchReturBeli.setBackground(new java.awt.Color(204, 255, 255));
        pnSearchReturBeli.setPreferredSize(new java.awt.Dimension(0, 70));
        pnSearchReturBeli.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        btnReturSearch.setText("Search");
        btnReturSearch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnReturSearchActionPerformed(evt);
            }
        });
        pnSearchReturBeli.add(btnReturSearch, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 40, 70, -1));

        btnReturShowAll.setText("All");
        btnReturShowAll.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnReturShowAllActionPerformed(evt);
            }
        });
        pnSearchReturBeli.add(btnReturShowAll, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 10, 70, -1));
        pnSearchReturBeli.add(txtSrcReturBeli, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 50, 210, 20));

        cbSrcReturBeli.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Kode Retur", "Kode Beli", "Supplier" }));
        pnSearchReturBeli.add(cbSrcReturBeli, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 30, 100, 20));

        infoReturBeli.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        infoReturBeli.setForeground(new java.awt.Color(0, 0, 204));
        infoReturBeli.setText("Search Retur Pembelian");
        pnSearchReturBeli.add(infoReturBeli, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 0, -1, 20));

        btnCloseReturBeli.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/close_small.png"))); // NOI18N
        btnCloseReturBeli.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCloseReturBeliActionPerformed(evt);
            }
        });
        pnSearchReturBeli.add(btnCloseReturBeli, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 10, 30, 20));

        pnReturBeli.add(pnSearchReturBeli, java.awt.BorderLayout.PAGE_START);

        pnShow.add(pnReturBeli, "returbeli");

        pnBeli.add(pnShow, java.awt.BorderLayout.CENTER);

        getContentPane().add(pnBeli, java.awt.BorderLayout.LINE_START);

        pnRetur.setBackground(new java.awt.Color(255, 255, 255));
        pnRetur.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204)));
        pnRetur.setLayout(new java.awt.BorderLayout());

        pnReturAtas.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        pnReturAtas.setPreferredSize(new java.awt.Dimension(354, 125));
        pnReturAtas.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel7.setForeground(new java.awt.Color(0, 0, 153));
        jLabel7.setText("Detail Retur Pembelian");
        pnReturAtas.add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, -1, -1));

        jLabel10.setText("Jum Retur");
        pnReturAtas.add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 90, -1, -1));

        jLabel11.setText("Bal");
        pnReturAtas.add(jLabel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 90, -1, -1));

        jLabel12.setText("Barang");
        pnReturAtas.add(jLabel12, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 30, -1, -1));

        btnAddRetur.setText("Add");
        btnAddRetur.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddReturActionPerformed(evt);
            }
        });
        pnReturAtas.add(btnAddRetur, new org.netbeans.lib.awtextra.AbsoluteConstraints(290, 90, -1, -1));

        txtReturBalRetur.setForeground(new java.awt.Color(255, 0, 0));
        txtReturBalRetur.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        txtReturBalRetur.setText("0");
        pnReturAtas.add(txtReturBalRetur, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 90, 30, -1));

        txtReturNmBrg.setEditable(false);
        pnReturAtas.add(txtReturNmBrg, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 50, 270, -1));

        txtReturBal.setEditable(false);
        txtReturBal.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        txtReturBal.setText("0");
        pnReturAtas.add(txtReturBal, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 70, 30, -1));

        jLabel13.setText("Jumlah");
        pnReturAtas.add(jLabel13, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 70, -1, -1));

        jLabel14.setText("Slop");
        pnReturAtas.add(jLabel14, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 90, -1, -1));

        jLabel15.setText("Bal");
        pnReturAtas.add(jLabel15, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 70, -1, -1));

        jLabel16.setText("Slop");
        pnReturAtas.add(jLabel16, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 70, -1, -1));

        txtReturSlop.setEditable(false);
        txtReturSlop.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        txtReturSlop.setText("0");
        pnReturAtas.add(txtReturSlop, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 70, 30, -1));

        txtReturSlopRetur.setForeground(new java.awt.Color(255, 0, 0));
        txtReturSlopRetur.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        txtReturSlopRetur.setText("0");
        pnReturAtas.add(txtReturSlopRetur, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 90, 30, -1));

        jLabel17.setText("Bks");
        pnReturAtas.add(jLabel17, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 70, -1, -1));

        jLabel18.setText("Bks");
        pnReturAtas.add(jLabel18, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 90, -1, -1));

        txtReturBks.setEditable(false);
        txtReturBks.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        txtReturBks.setText("0");
        pnReturAtas.add(txtReturBks, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 70, 30, -1));

        txtReturBksRetur.setForeground(new java.awt.Color(255, 0, 0));
        txtReturBksRetur.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        txtReturBksRetur.setText("0");
        pnReturAtas.add(txtReturBksRetur, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 90, 30, -1));

        txtReturKdBrg.setEditable(false);
        txtReturKdBrg.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        pnReturAtas.add(txtReturKdBrg, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 30, 120, -1));

        pnRetur.add(pnReturAtas, java.awt.BorderLayout.PAGE_START);

        pnReturBawah.setLayout(new java.awt.BorderLayout());

        tbDetailRetur.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "Kode Brg", "Nama Barang", "Jumlah"
            }
        ));
        tbDetailRetur.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        tbDetailRetur.setGridColor(new java.awt.Color(255, 102, 102));
        tbDetailRetur.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                tbDetailReturMousePressed(evt);
            }
        });
        tbDetailRetur.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tbDetailReturKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tbDetailReturKeyReleased(evt);
            }
        });
        spDetailRetur.setViewportView(tbDetailRetur);

        pnReturBawah.add(spDetailRetur, java.awt.BorderLayout.CENTER);

        jPanel2.setPreferredSize(new java.awt.Dimension(368, 20));

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel6.setForeground(new java.awt.Color(0, 0, 153));
        jLabel6.setText("Detail Retur Pembelian");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel6)
                .addContainerGap(231, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jLabel6)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pnReturBawah.add(jPanel2, java.awt.BorderLayout.PAGE_START);

        jPanel3.setPreferredSize(new java.awt.Dimension(354, 25));
        jPanel3.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        btnReturOk.setText("OK");
        btnReturOk.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnReturOkActionPerformed(evt);
            }
        });
        jPanel3.add(btnReturOk, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 0, -1, -1));

        btnReturCancel.setText("Cancel");
        btnReturCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnReturCancelActionPerformed(evt);
            }
        });
        jPanel3.add(btnReturCancel, new org.netbeans.lib.awtextra.AbsoluteConstraints(290, 0, -1, -1));

        pnReturBawah.add(jPanel3, java.awt.BorderLayout.PAGE_END);

        pnRetur.add(pnReturBawah, java.awt.BorderLayout.CENTER);

        getContentPane().add(pnRetur, java.awt.BorderLayout.CENTER);

        setBounds(0, 0, 753, 406);
    }// </editor-fold>//GEN-END:initComponents

    private void formInternalFrameClosing(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameClosing
        int clossing;
        clossing = JOptionPane.showConfirmDialog(this,
                "Tutup Retur Pembelian?",
                "Konfirmasi",
                JOptionPane.YES_NO_OPTION);
        if (clossing == 0){
            this.dispose();
            FormMain.isfrPem = false;
        }
    }//GEN-LAST:event_formInternalFrameClosing

    private void tbBeliMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbBeliMousePressed
        getDataFromBeli();
}//GEN-LAST:event_tbBeliMousePressed

    private void tbBeliKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tbBeliKeyPressed
        // TODO add your handling code here:
        getDataFromBeli();
}//GEN-LAST:event_tbBeliKeyPressed

    private void tbBeliKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tbBeliKeyReleased
        // TODO add your handling code here:
        getDataFromBeli();
}//GEN-LAST:event_tbBeliKeyReleased

    private void btnShowAllBeliActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnShowAllBeliActionPerformed
        // TODO add your handling code here:
        tampilAllBeli();
}//GEN-LAST:event_btnShowAllBeliActionPerformed

    private void btnSearchBeliActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSearchBeliActionPerformed
        // TODO add your handling code here:
        tampilSearchBeli();
}//GEN-LAST:event_btnSearchBeliActionPerformed

    private void dcTglReturBeliPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_dcTglReturBeliPropertyChange
        // TODO add your handling code here:
        if(dcTglReturBeli.getDate()!=null){
            //format yyyy-MM-dd utk mysql
            SimpleDateFormat formatTgl = new SimpleDateFormat("yyyy-MM-dd");
            sTglRBeli= formatTgl.format(dcTglReturBeli.getDate());
        }
}//GEN-LAST:event_dcTglReturBeliPropertyChange

    private void btnCariBeliActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCariBeliActionPerformed
        // TODO add your handling code here:
        CardLayout cl = (CardLayout)(pnShow.getLayout());
        cl.show(pnShow, "beli");
        tampilSearchBeli();
        //kosongkanNew();
}//GEN-LAST:event_btnCariBeliActionPerformed

    private void txtKdReturBeliKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtKdReturBeliKeyReleased
        // TODO add your handling code here:
}//GEN-LAST:event_txtKdReturBeliKeyReleased

    private void btnCloseBeliActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCloseBeliActionPerformed
        // TODO add your handling code here:
        CardLayout cl = (CardLayout)(pnShow.getLayout());
        cl.show(pnShow, "detailbeli");
    }//GEN-LAST:event_btnCloseBeliActionPerformed

    private void btnNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNewActionPerformed
        // TODO add your handling code here:
        kosongkanNew();
}//GEN-LAST:event_btnNewActionPerformed

    private void tbReturBeliMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbReturBeliMousePressed
        getDataFromReturBeli();
}//GEN-LAST:event_tbReturBeliMousePressed

    private void tbReturBeliKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tbReturBeliKeyPressed
        // TODO add your handling code here:
        getDataFromReturBeli();
}//GEN-LAST:event_tbReturBeliKeyPressed

    private void tbReturBeliKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tbReturBeliKeyReleased
        // TODO add your handling code here:
        getDataFromReturBeli();
}//GEN-LAST:event_tbReturBeliKeyReleased

    private void btnReturSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnReturSearchActionPerformed
        // TODO add your handling code here:
        tampilSearchReturBeli();
        //gj/btnEdit.setEnabled(false);
        //gj/btnDelete.setEnabled(false);
}//GEN-LAST:event_btnReturSearchActionPerformed

    private void btnReturShowAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnReturShowAllActionPerformed
        // TODO add your handling code here:
        tampilReturBeli();
}//GEN-LAST:event_btnReturShowAllActionPerformed

    private void tbDetailBeliMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbDetailBeliMousePressed
        getDataFromDetailBeli();
}//GEN-LAST:event_tbDetailBeliMousePressed

    private void tbDetailBeliKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tbDetailBeliKeyPressed
        // TODO add your handling code here:
        getDataFromDetailBeli();
}//GEN-LAST:event_tbDetailBeliKeyPressed

    private void tbDetailBeliKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tbDetailBeliKeyReleased
        // TODO add your handling code here:
        getDataFromDetailBeli();
}//GEN-LAST:event_tbDetailBeliKeyReleased

    private void btnCloseReturBeliActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCloseReturBeliActionPerformed
        // TODO add your handling code here:
        CardLayout cl = (CardLayout)(pnShow.getLayout());
        cl.show(pnShow, "detailbeli");
        
    }//GEN-LAST:event_btnCloseReturBeliActionPerformed

    private void tbDetailReturMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbDetailReturMousePressed
        // TODO add your handling code here:
    }//GEN-LAST:event_tbDetailReturMousePressed

    private void tbDetailReturKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tbDetailReturKeyPressed
        // TODO add your handling code here:
    }//GEN-LAST:event_tbDetailReturKeyPressed

    private void tbDetailReturKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tbDetailReturKeyReleased
        // TODO add your handling code here:
    }//GEN-LAST:event_tbDetailReturKeyReleased

    private void btnAddReturActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddReturActionPerformed
        // TODO add your handling code here:
        addData();
    }//GEN-LAST:event_btnAddReturActionPerformed

    private void btnReturCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnReturCancelActionPerformed
        // TODO add your handling code here:
        int clossing;
        clossing = JOptionPane.showConfirmDialog(this,
                "Batalkan retur pembelian?",
                "Konfirmasi",
                JOptionPane.YES_NO_OPTION);
        if (clossing == 0){
            this.dispose();
            FormMain.isfrPem = false;
        }
    }//GEN-LAST:event_btnReturCancelActionPerformed

    private void btnReturOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnReturOkActionPerformed
        // TODO add your handling code here:
        int yakin;
        yakin = JOptionPane.showConfirmDialog(this,
                "Apakah Anda yakin?",
                "Konfirmasi",
                JOptionPane.YES_NO_OPTION);
        if (yakin == 0){
            insertDataRetur();
        }
    }//GEN-LAST:event_btnReturOkActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAddRetur;
    private javax.swing.JButton btnCariBeli;
    private javax.swing.JButton btnCloseBeli;
    private javax.swing.JButton btnCloseReturBeli;
    private javax.swing.JButton btnNew;
    private javax.swing.JButton btnReturCancel;
    private javax.swing.JButton btnReturOk;
    private javax.swing.JButton btnReturSearch;
    private javax.swing.JButton btnReturShowAll;
    private javax.swing.JButton btnSearchBeli;
    private javax.swing.JButton btnShowAllBeli;
    private javax.swing.JComboBox cbSrcBeli;
    private javax.swing.JComboBox cbSrcReturBeli;
    private com.toedter.calendar.JDateChooser dcTglReturBeli;
    private javax.swing.JLabel infoBeli;
    private javax.swing.JLabel infoReturBeli;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel pnAtas1;
    private javax.swing.JPanel pnBeli;
    private javax.swing.JPanel pnBeliAtas;
    private javax.swing.JPanel pnCrBeli;
    private javax.swing.JPanel pnDaftarBeli;
    private javax.swing.JPanel pnDetailBeli;
    private javax.swing.JPanel pnJudul;
    private javax.swing.JPanel pnRetur;
    private javax.swing.JPanel pnReturAtas;
    private javax.swing.JPanel pnReturBawah;
    private javax.swing.JPanel pnReturBeli;
    private javax.swing.JPanel pnSearchReturBeli;
    private javax.swing.JPanel pnShow;
    private javax.swing.JScrollPane spBeli;
    private javax.swing.JScrollPane spDetailBeli;
    private javax.swing.JScrollPane spDetailRetur;
    private javax.swing.JScrollPane spReturBeli;
    private javax.swing.JTable tbBeli;
    private javax.swing.JTable tbDetailBeli;
    private javax.swing.JTable tbDetailRetur;
    private javax.swing.JTable tbReturBeli;
    private javax.swing.JTextField txtKdBeli;
    private javax.swing.JTextField txtKdReturBeli;
    private javax.swing.JTextField txtKdSupplier;
    private javax.swing.JTextField txtNmSupplier;
    private javax.swing.JTextField txtReturBal;
    private javax.swing.JTextField txtReturBalRetur;
    private javax.swing.JTextField txtReturBks;
    private javax.swing.JTextField txtReturBksRetur;
    private javax.swing.JTextField txtReturKdBrg;
    private javax.swing.JTextField txtReturNmBrg;
    private javax.swing.JTextField txtReturSlop;
    private javax.swing.JTextField txtReturSlopRetur;
    private javax.swing.JTextField txtSrcBeli;
    private javax.swing.JTextField txtSrcReturBeli;
    private javax.swing.JTextField txtTglBeli;
    // End of variables declaration//GEN-END:variables

    private void kosongkan(){
        txtKdBeli.setText("");
        txtKdSupplier.setText("");
        txtNmSupplier.setText("");
        txtSrcReturBeli.setText("");
        //gj/btnEdit.setEnabled(false);

        //gj/btnReturOk.setEnabled(true);
        //gj/btnReturCancel.setEnabled(true);
        //gj/btnAddRetur.setEnabled(true);

        //gj/btnDelete.setEnabled(false);
        //btnEdit.setText("Edit");
        //gj/btnDelete.setText("Delete");
    }
    
    private void kosongkanDetailRetur(){
        txtReturKdBrg.setText("");
        txtReturNmBrg.setText("");
        
        txtReturBal.setText("0");
        txtReturSlop.setText("0");
        txtReturBks.setText("0");

        txtReturBalRetur.setText("0");
        txtReturSlopRetur.setText("0");
        txtReturBksRetur.setText("0");
    }

    private void kosongkanNew(){
        setKdReturBeli();
        txtKdBeli.setText("");
        txtKdSupplier.setText("");
        txtNmSupplier.setText("");
        txtSrcReturBeli.setText("");
        //btnEdit.setText("Save");
        //gj/btnDelete.setText("Cancel");
        //gj/btnEdit.setEnabled(false);

        //gj/btnReturOk.setEnabled(true);
        //gj/btnReturCancel.setEnabled(true);
        //gj/btnAddRetur.setEnabled(true);

        //gj/btnDelete.setEnabled(true);

        dcTglReturBeli.setDate(getDateTime());
        txtTglBeli.setText("");

        kosongkanDetailRetur();

        tbDetailBeli.getTableHeader().setReorderingAllowed(false);
        Object[] Baris={"Kode Brg", "Nama Brg", "Bal", "Slop", "Bks"};
        DftTabModeDetailBeli=new DefaultTableModel(null,Baris);
        tbDetailBeli.setModel(DftTabModeDetailBeli);

        tbDetailRetur.getTableHeader().setReorderingAllowed(false);
        Object[] Baris2={"Kode Brg", "Nama Brg", "Bal", "Slop", "Bks"};
        DftTabModeDetailReturBeli=new DefaultTableModel(null,Baris2);
        tbDetailRetur.setModel(DftTabModeDetailReturBeli);
        
    }
    private void tampilReturBeli(){
        Object[] Baris={"Kode Retur", "Kode Beli", "Supplier", "Tanggal"};
        DftTabModeReturBeli=new DefaultTableModel(null,Baris);
        tbReturBeli.setModel(DftTabModeReturBeli);

        try {
            java.sql.Statement stmt = conn.createStatement();
            java.sql.ResultSet rslt = stmt.executeQuery("SELECT br.*, s.nmSup " +
                    "FROM tbeli_retur br, tsup s " +
                    "WHERE br.kdSup = s.kdSup " +
                    "ORDER BY idReturBeli");
            while (rslt.next()) {
                String sKdRBeli = rslt.getString("idReturBeli");
                String sKdBeli = rslt.getString("idBeli");
                String sNmSup = rslt.getString("nmSup");
                //Date dRBeli = rslt.getDate("tgl_retur_beli");
                //SimpleDateFormat formatTgl = new SimpleDateFormat("yyyy-MM-dd");
                SimpleDateFormat formatTgl = new SimpleDateFormat("dd-MM-yyyy");
                String sTgl= formatTgl.format(rslt.getDate("tgl_retur_beli"));

                String[] dataField = {sKdRBeli, sKdBeli, sNmSup, sTgl};
                DftTabModeReturBeli.addRow(dataField);
                int widths[] = {100, 100, 200, 100};
                for(int i=0;i<tbReturBeli.getColumnCount();i++){
                    TableColumn column = tbReturBeli.getColumnModel().getColumn(i);
                    column.setPreferredWidth(widths[i]);
                }
            }
        }
        catch(SQLException e) {
            System.out.println("gagal : " + e.toString());
        }
    }

    private void tampilDetailBeli(){
        Object[] Baris={"Kode Brg", "Nama Brg", "Bal", "Slop", "Bks"};
        DftTabModeDetailBeli=new DefaultTableModel(null,Baris);
        tbDetailBeli.setModel(DftTabModeDetailBeli);

        try {
            java.sql.Statement stmt = conn.createStatement();
            java.sql.ResultSet rslt = stmt.executeQuery(
                    "SELECT db.*, b.nmBrg FROM tbeli_detail db, tbrg b " +
                    "WHERE db.idBeli='" + txtKdBeli.getText() + "' AND " +
                    "db.kdBrg=b.kdBrg");
            while (rslt.next()) {
                //String sKdRBeli = rslt.getString("idReturBeli");
                String sKdBrg = rslt.getString("kdBrg");
                String sNmBrg = rslt.getString("nmBrg");
                String sBal = rslt.getString("bal");
                String sSlop = rslt.getString("slop");
                String sBks = rslt.getString("bks");
                
                String[] dataField = {sKdBrg, sNmBrg, sBal, sSlop, sBks};
                DftTabModeDetailBeli.addRow(dataField);
                int widths[] = {110, 170, 30, 30, 30};
                for(int i=0;i<tbDetailBeli.getColumnCount();i++){
                    TableColumn column = tbDetailBeli.getColumnModel().getColumn(i);
                    column.setPreferredWidth(widths[i]);
                }
            }
        }
        catch(SQLException e) {
            System.out.println("gagal : " + e.toString());
        }
    }
    
    private void tampilSearchReturBeli(){
        String srcby = "";
        if(cbSrcReturBeli.getSelectedItem().toString().equals("Kode Retur")){
            srcby = "idReturBeli";
        }else if(cbSrcReturBeli.getSelectedItem().toString().equals("Kode Beli")){
            srcby = "idBeli";
        }else if(cbSrcReturBeli.getSelectedItem().toString().equals("Supplier")){
            srcby = "nmSup";
        }

        Object[] Baris={"Kode Retur","Kode Beli", "Supplier", "Tanggal"};
        DftTabModeReturBeli=new DefaultTableModel(null,Baris);
        tbReturBeli.setModel(DftTabModeReturBeli);

        try {
            java.sql.Statement stmt = conn.createStatement();
            java.sql.ResultSet rslt = stmt.executeQuery(
                    "SELECT br.*, s.nmSup " +
                    "FROM tbeli_retur br, tsup s " +
                    "WHERE br.kdSup = s.kdSup " +
                    "AND UPPER(" + srcby +
                    ") like UPPER('%" +
                    txtSrcReturBeli.getText() + "%') ORDER BY idReturBeli");
            while (rslt.next()) {
                String sKdRBeli = rslt.getString("idReturBeli");
                String sKdBeli = rslt.getString("idBeli");
                String sNmSup = rslt.getString("nmSup");
                SimpleDateFormat formatTgl = new SimpleDateFormat("dd-MM-yyyy");
                String sTgl= formatTgl.format(rslt.getDate("tgl_retur_beli"));

                String[] dataField = {sKdRBeli, sKdBeli, sNmSup, sTgl};
                DftTabModeReturBeli.addRow(dataField);
                int widths[] = {100,100, 200, 100};
                for(int i=0;i<tbReturBeli.getColumnCount();i++){
                    TableColumn column = tbReturBeli.getColumnModel().getColumn(i);
                    column.setPreferredWidth(widths[i]);
                }
            }

        }
        catch(SQLException e) {
            System.out.println("gagal! : " + e.toString());
        }
    }

    private void tampilSearchBeli(){
        String srcby = "";
        if(cbSrcBeli.getSelectedItem().toString().equals("Kode Beli")){
            srcby = "idBeli";
        }else{
            srcby = "nmSup";
        }

        Object[] Baris={"Kode Beli","Supplier", "Tanggal"};
        DftTabModeBeli=new DefaultTableModel(null,Baris);
        tbBeli.setModel(DftTabModeBeli);
        int widths[] = {100, 200, 100};
        for(int i=0;i<tbBeli.getColumnCount();i++){
            TableColumn column = tbBeli.getColumnModel().getColumn(i);
            column.setPreferredWidth(widths[i]);
        }
        try {
            java.sql.Statement stmt = conn.createStatement();
            java.sql.ResultSet rslt = stmt.executeQuery(
                    "SELECT b.*, s.nmSup FROM tbeli b, tsup s " +
                    "WHERE b.kdSup=s.kdSup AND " +
                    "UPPER(" + srcby +
                    ") like UPPER('%" +
                    txtSrcBeli.getText() + "%')");
            while (rslt.next()) {
                String sIdBeli = rslt.getString("idBeli");
                String sNmSup = rslt.getString("nmSup");
                SimpleDateFormat formatTgl = new SimpleDateFormat("dd-MM-yyyy");
                String sTgl= formatTgl.format(rslt.getDate("tgl_beli"));

                String[] dataField = {sIdBeli, sNmSup, sTgl};
                DftTabModeBeli.addRow(dataField);
            }
        }
        catch(SQLException e) {
            System.out.println("gagal : " + e.toString());
        }
    }

    private void deleteData(){
            try {
                int deleting;
                deleting = JOptionPane.showConfirmDialog(this,
                        "Apakah Anda yakin akan menghapus "

                        //+ cbKodeKota.getSelectedItem().toString() +" "
                        +txtKdReturBeli.getText() +"?",
                        "Konfirmasi",
                        JOptionPane.YES_NO_OPTION);
                if (deleting == 0){

                    PreparedStatement pStatement = null;
                    String sql = "DELETE FROM tbeli_retur " +
                            "WHERE idReturBeli=? ";
                    pStatement = conn.prepareStatement(sql);

                    pStatement.setString(1, txtKdReturBeli.getText());

                    int intTambah = pStatement.executeUpdate();
                    if (intTambah >0){
                        JOptionPane.showMessageDialog(this,
                                "Delete sukses", "Informasi",
                                JOptionPane.INFORMATION_MESSAGE);

                    }else {
                        JOptionPane.showMessageDialog(this,
                                "Delete gagal", "Informasi",
                                JOptionPane.INFORMATION_MESSAGE);
                    }

                    pStatement.close();

                    kosongkan();
                    tampilReturBeli();
                }
            } catch(SQLException e){
                System.out.println("koneksi gagal " + e.toString());
            }
    }
    private boolean isDuplicatePKey(){
        String pKey = txtKdReturBeli.getText();
        boolean result = true;
        Integer row = 0;

        try {
            java.sql.Statement stmt = conn.createStatement();
            java.sql.ResultSet rslt = stmt.executeQuery("Select * from tbeli_retur " +
                    "WHERE idReturBeli=" +
                    "'" +pKey+ "'");
            while (rslt.next()) {
                row = rslt.getRow();
            }
                if(row > 0){
                    //JOptionPane.showMessageDialog(this, "Kode "+pKey+" sudah ada"
                    //        ,"Peringatan",JOptionPane.WARNING_MESSAGE);
                    result = true;
                }else{
                    result = false;
                }
            System.out.println("row : " + row);
        }
        catch(SQLException e) {
            System.out.println("gagal : " + e.toString());
        }
        return result;
    }
    private void insertData(){
        java.sql.PreparedStatement pStatement = null;
        String sql = "INSERT INTO tbeli_retur " +
                "(idReturBeli, idBeli, tgl_retur_beli, kdSup, user_id) " +
                "VALUES (?,?,?, ?,?)";
        try {
            pStatement = conn.prepareStatement(sql);
            pStatement.setString(1, txtKdReturBeli.getText());
            pStatement.setString(2, txtKdBeli.getText());
            //for date
            pStatement.setString(3, sTglRBeli);
            //pStatement.setString(4, txtKdSupplier.getText());
            pStatement.setString(5, "admin");

            int intTambah = pStatement.executeUpdate();
            if (intTambah>0){
                JOptionPane.showMessageDialog(this,
                        "Penambahan sukses", "Informasi",
                        JOptionPane.INFORMATION_MESSAGE);
            }else{
                JOptionPane.showMessageDialog(this,
                        "Penambahan gagal", "Informasi",
                        JOptionPane.INFORMATION_MESSAGE);
            }
            pStatement.close();

            kosongkan();
            tampilReturBeli();
            setKdReturBeli();

        }
        catch(SQLException e){
            System.out.println("koneksi gagal " + e.toString());
        }

    }

     private void editData(){
        try {
            PreparedStatement pStatement = null;
            String sql = "UPDATE tbeli_retur " +
                    "SET idBeli=?, tgl_retur_beli=?, " +
                    "kdSup=? " +
                    "WHERE idReturBeli=? ";
            pStatement = conn.prepareStatement(sql);

            pStatement.setString(1, txtKdBeli.getText());
            pStatement.setString(2, sTglRBeli);
            //pStatement.setString(3, txtKdSupplier.getText());
            pStatement.setString(4, txtKdReturBeli.getText());

            int intTambah = pStatement.executeUpdate();
            if (intTambah >0){
                JOptionPane.showMessageDialog(this,
                        "Edit sukses", "Informasi",
                        JOptionPane.INFORMATION_MESSAGE);

            }else {
                JOptionPane.showMessageDialog(this,
                        "Edit gagal", "Informasi",
                        JOptionPane.INFORMATION_MESSAGE);
            }

            pStatement.close();
            kosongkan();
            tampilReturBeli();

        } catch(SQLException e){
            System.out.println("koneksi gagal " + e.toString());
        }
    }
    private void getDataFromReturBeli(){
        Object oIdRBeli, oIdBeli;

        oIdRBeli = tbReturBeli.getValueAt(tbReturBeli.getSelectedRow(), 0);
        oIdBeli = tbReturBeli.getValueAt(tbReturBeli.getSelectedRow(), 1);

        try {
            java.sql.Statement stmt = conn.createStatement();
            java.sql.ResultSet rslt = stmt.executeQuery("SELECT br.*, s.nmSup " +
                    "FROM tbeli_retur br, tsup s " +
                    "WHERE br.kdSup = s.kdSup " +
                    "AND idReturBeli=" +
                    "'" +oIdRBeli+ "'");
            while (rslt.next()) {
                txtKdSupplier.setText(rslt.getString("kdSup"));
                txtNmSupplier.setText(rslt.getString("nmSup"));
            }
        }
        catch(SQLException e) {
            System.out.println("gagal : " + e.toString());
        }

        txtKdReturBeli.setText(oIdRBeli.toString());
        txtKdBeli.setText(oIdBeli.toString());

        //gj/btnEdit.setEnabled(true);

        //gj/btnReturOk.setEnabled(false);
        //gj/btnReturCancel.setEnabled(false);
        //gj/btnAddRetur.setEnabled(false);

        //gj/btnDelete.setEnabled(true);
        //gj/btnEdit.setText("Edit");
        //gj/btnDelete.setText("Delete");
    }

    private void setKdReturBeli(){
        String idReturBeli = "";
        Integer noUrut = 0;
        try {
            java.sql.Statement stmt = conn.createStatement();
            java.sql.ResultSet rslt = stmt.executeQuery(
                    "SELECT * FROM tbeli_retur");
            while (rslt.next()) {
                noUrut = rslt.getRow();
                idReturBeli = rslt.getString("idReturBeli");
            }
        }
        catch(SQLException e) {
            System.out.println("gagal : " + e.toString());
        }

        if(idReturBeli.equals("")){
            idReturBeli = "RB-0000000";
            idReturBeli = idReturBeli.substring(3);
            noUrut = Integer.parseInt(idReturBeli);
        }
        System.out.println(idReturBeli);

        noUrut++;

        java.text.DecimalFormat nft = new java.text.DecimalFormat("#0000000.###");
        nft.setDecimalSeparatorAlwaysShown(false);

        txtKdReturBeli.setText("RB-"+nft.format(noUrut));
        while(isDuplicatePKey()){
            noUrut++;
            txtKdReturBeli.setText("RB-"+nft.format(noUrut));
        }
        System.out.println("RB-"+nft.format(noUrut));
    }

    private void getDataFromBeli(){
        Object oIdBeli;//, oKdSup;//, oKet;//, oTest;

        oIdBeli = tbBeli.getValueAt(tbBeli.getSelectedRow(), 0);
        //oKdSup = tbBeli.getValueAt(tbBeli.getSelectedRow(), 1);
        try {
            java.sql.Statement stmt = conn.createStatement();
            java.sql.ResultSet rslt = stmt.executeQuery(
                    "SELECT b.*, s.nmSup " +
                    "FROM tbeli b, tsup s WHERE " +
                    "b.kdSup = s.kdSup " +
                    "AND idBeli=" +
                    "'" +oIdBeli+ "'");
            while (rslt.next()) {
                txtKdSupplier.setText(rslt.getString("kdSup"));
                txtNmSupplier.setText(rslt.getString("nmSup"));
                SimpleDateFormat formatTgl = new SimpleDateFormat("dd-MM-yyyy");
                String sTgl= formatTgl.format(rslt.getDate("tgl_beli"));
                txtTglBeli.setText(sTgl);
            }
        }
        catch(SQLException e) {
            System.out.println("gagal : " + e.toString());
        }

        txtKdBeli.setText(oIdBeli.toString());
        tampilDetailBeli();
        //txtKdSupplier.setText(oKdSup.toString());
    }    

    private void getDataFromDetailBeli(){
        if(!txtKdBeli.getText().equals("")){
        Object oKdBrg, oNmBrg, oBal, oSlop, oBks;

        oKdBrg = tbDetailBeli.getValueAt(tbDetailBeli.getSelectedRow(), 0);
        oNmBrg = tbDetailBeli.getValueAt(tbDetailBeli.getSelectedRow(), 1);
        oBal = tbDetailBeli.getValueAt(tbDetailBeli.getSelectedRow(), 2);
        oSlop = tbDetailBeli.getValueAt(tbDetailBeli.getSelectedRow(), 3);
        oBks = tbDetailBeli.getValueAt(tbDetailBeli.getSelectedRow(), 4);

        txtReturKdBrg.setText(oKdBrg.toString());
        txtReturNmBrg.setText(oNmBrg.toString());
        txtReturBal.setText(oBal.toString());
        txtReturSlop.setText(oSlop.toString());
        txtReturBks.setText(oBks.toString());

        if(isSameKdBrg(txtReturKdBrg.getText())){
            System.out.println("Sama!");
            //udpate stok
            int rows = tbDetailRetur.getRowCount();
            for (int i=0; i< rows; i++) {
                if(txtReturKdBrg.getText().equalsIgnoreCase(tbDetailRetur.getValueAt(i, 0).toString())){
                Integer iBal = Integer.parseInt(txtReturBal.getText());
                Integer iSlop = Integer.parseInt(txtReturSlop.getText());
                Integer iBks = Integer.parseInt(txtReturBks.getText());

                //bKetemu = true;
                //Integer iBals = Integer.parseInt(txtReturBal.getText());
                //Integer iSlops = Integer.parseInt(txtReturSlop.getText());
                //Integer iBkss = Integer.parseInt(txtReturBks.getText());
                //iBals = iBals - iBal;
                //txtReturBal.setText(iBals.toString());
                iBal = iBal - Integer.parseInt(tbDetailRetur.getValueAt(i, 2).toString());
                txtReturBal.setText(iBal.toString());
                //tbDetailRetur.setValueAt(iBal, i, 2);
                //iSlops = iSlops - iSlop;
                //txtReturSlop.setText(iSlops.toString());
                iSlop = iSlop - Integer.parseInt(tbDetailRetur.getValueAt(i, 3).toString());
                txtReturSlop.setText(iSlop.toString());
                //tbDetailRetur.setValueAt(iSlop, i, 3);
                //iBkss = iBkss - iBks;
                //txtReturBks.setText(iBkss.toString());
                iBks = iBks - Integer.parseInt(tbDetailRetur.getValueAt(i, 4).toString());
                txtReturBks.setText(iBks.toString());
                //tbDetailRetur.setValueAt(iBks, i, 4);
                }
            }
            }
        
        }


        /*
        try {
            java.sql.Statement stmt = conn.createStatement();
            java.sql.ResultSet rslt = stmt.executeQuery(
                    "SELECT db.*, b.nmBrg FROM tbeli_detail db, tbrg b " +
                    "WHERE db.kdBrg='" + oKdBrg + "' AND " +
                    "db.kdBrg=b.kdBrg");
            while (rslt.next()) {
                txtReturNmBrg.setText(rslt.getString("nmBrg"));
                txtReturBal.setText("bal");
                txtReturSlop.setText("slop");
                txtReturBks.setText("bks");
            }
        }
        catch(SQLException e) {
            System.out.println("gagal : " + e.toString());
        }
         * 
         */

        
        //tampilDetailBeli();
        //txtKdSupplier.setText(oKdSup.toString());
    }
    

    private void tampilAllBeli(){
        txtSrcBeli.setText("");
        Object[] Baris={"Kode Beli","Supplier","Tanggal"};
        DftTabModeBeli=new DefaultTableModel(null,Baris);
        tbBeli.setModel(DftTabModeBeli);

        try {
            java.sql.Statement stmt = conn.createStatement();
            java.sql.ResultSet rslt = stmt.executeQuery(
                    "SELECT b.*, s.nmSup FROM tbeli b, tsup s " +
                    "WHERE b.kdSup=s.kdSup " +
                    "ORDER BY idBeli");
            while (rslt.next()) {
                String sIdBeli = rslt.getString("idBeli");
                String sNmSup = rslt.getString("nmSup");
                SimpleDateFormat formatTgl = new SimpleDateFormat("dd-MM-yyyy");
                String sTgl= formatTgl.format(rslt.getDate("tgl_beli"));

                String[] dataField = {sIdBeli, sNmSup, sTgl};
                DftTabModeBeli.addRow(dataField);
                int widths[] = {120, 300};
                for(int i=0;i<tbBeli.getColumnCount();i++){
                    TableColumn column = tbBeli.getColumnModel().getColumn(i);
                    column.setPreferredWidth(widths[i]);
                }
            }
        }
        catch(SQLException e) {
            System.out.println("gagal : " + e.toString());
        }
    }

    private void addData(){
        //cek kdsupplier
        if(txtNmSupplier.getText().equals("")) {
                JOptionPane.showMessageDialog(this, "Data tidak valid, " +
                        "","Error",
                    JOptionPane.ERROR_MESSAGE);
        //cek kdbarang
        }else if(txtReturNmBrg.getText().equals("")){
                JOptionPane.showMessageDialog(this, "Data tidak valid, " +
                        "data barang harus terisi","Error",
                    JOptionPane.ERROR_MESSAGE);
        }else{
            //cek input stok
            if(validateNumber(txtReturBalRetur.getText()) &&
               validateNumber(txtReturSlopRetur.getText())&&
               validateNumber(txtReturBksRetur.getText())){

               System.out.println("Correct Number");
               Integer iBal = Integer.parseInt(txtReturBalRetur.getText());
               Integer iSlop = Integer.parseInt(txtReturSlopRetur.getText());
               Integer iBks = Integer.parseInt(txtReturBksRetur.getText());
               Integer allStokInput = (iBal * 200) + (iSlop * 10) + (iBks);

                if(  iBal >= 1 ||
                     iSlop >= 1 ||
                     iBks >= 1 ){
                    //cek data sama
                    //System.out.println("txtKdBrg : " + txtKdBrg.getText());
                    if(isSameKdBrg(txtReturKdBrg.getText())){
                        System.out.println("Sama!");
                        //udpate stok
                        int rows = tbDetailRetur.getRowCount();
                        for (int i=0; i< rows; i++) {
                        if(txtReturKdBrg.getText().equalsIgnoreCase(tbDetailRetur.getValueAt(i, 0).toString())){
                            //bKetemu = true;
                            //Integer iBals = Integer.parseInt(txtReturBal.getText());
                            //Integer iSlops = Integer.parseInt(txtReturSlop.getText());
                            //Integer iBkss = Integer.parseInt(txtReturBks.getText());

                            //iBals = iBals - iBal;
                            //txtReturBal.setText(iBals.toString());
                            iBal = iBal + Integer.parseInt(tbDetailRetur.getValueAt(i, 2).toString());
                            tbDetailRetur.setValueAt(iBal, i, 2);

                            //iSlops = iSlops - iSlop;
                            //txtReturSlop.setText(iSlops.toString());
                            iSlop = iSlop + Integer.parseInt(tbDetailRetur.getValueAt(i, 3).toString());
                            tbDetailRetur.setValueAt(iSlop, i, 3);
                            
                            //iBkss = iBkss - iBks;
                            //txtReturBks.setText(iBkss.toString());
                            iBks = iBks + Integer.parseInt(tbDetailRetur.getValueAt(i, 4).toString());
                            tbDetailRetur.setValueAt(iBks, i, 4);
                        }
                        }
                    }else{

                    //noItem = noItem + 1;

                    //Integer iHarga = Integer.parseInt(txtHarga.getText());

                    //Integer subtotal =  allStokInput * iHarga;
                    //Kode Brg", "Nama Brg", "Bal", "Slop", "Bks"
                    String[] dataField = {txtReturKdBrg.getText(), txtReturNmBrg.getText(),
                    iBal.toString(),iSlop.toString(),iBks.toString()};
                    DftTabModeDetailReturBeli.addRow(dataField);
                    }
                    int widths[] = {110, 170, 30, 30, 30};
                    for(int i=0;i<tbDetailRetur.getColumnCount();i++){
                        TableColumn column = tbDetailRetur.getColumnModel().getColumn(i);
                        column.setPreferredWidth(widths[i]);
                    }

                    //hitungHTotal();

                    //4 STOK
                    //aBal[noItem] = Integer.parseInt(txtBalDB.getText());
                    //aSlop[noItem] = Integer.parseInt(txtSlopDB.getText());
                    //aBks[noItem] = Integer.parseInt(txtBksDB.getText());

                    //txtHargaAkhir.setText(toRp(tHarga));
                    
                    kosongkanDetailRetur();
                    btnReturOk.setEnabled(true);
                    //*/
            }else{
                JOptionPane.showMessageDialog(this, "Data tidak valid, " +
                        "Bal, Slop, atau Bungkus harus diisi atau stok barang kurang","Error",
                    JOptionPane.ERROR_MESSAGE);
            }
            }else{
                System.out.println("Incorrect Number");
                JOptionPane.showMessageDialog(this, "Data tidak valid, " +
                        "Bal, Slop, atau Bungkus harus diisi Angka","Error",
                    JOptionPane.ERROR_MESSAGE);
            }
        }
    }

    public static boolean validateNumber(String num) {
        try {
            Integer.parseInt(num);
            return true;
        } catch (Exception e) {
            return false;
        }
       /*
     * if(validateNumber(num)){
            System.out.println("Correct Number");
        }else{
            System.out.println("Incorrect Number");
        }
     */
    }

    private boolean isSameKdBrg(String x){
        int rows = tbDetailRetur.getRowCount();
        boolean bKetemu = false;
        //tHarga = 0; //buat lagi ke nol, soalnya diSum di tabel transaksi
        for (int i=0; i< rows; i++) {
            //tHarga = tHarga + Integer.parseInt(tbTransaksi.getValueAt(i, 7).toString());
            if(x.equalsIgnoreCase(tbDetailRetur.getValueAt(i, 0).toString())){
                bKetemu = true;
            }
        }
        return bKetemu;
    }

    private Date getDateTime(){
        //teu kapake//DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
        Date date = new Date();
        return date;
        //return dateFormat.format(date);
    }

    private void insertDataRetur(){
        java.sql.PreparedStatement pStatement = null;
        String sql = "INSERT INTO tbeli_retur " +
                "(idReturBeli, tgl_retur_beli, " +
                "idBeli, kdSup, user_id) " +
                "VALUES (?,?,?,?,?)";
        try {
            pStatement = conn.prepareStatement(sql);
            pStatement.setString(1, txtKdReturBeli.getText());
            //for date
            pStatement.setString(2, sTglRBeli);

            pStatement.setString(3, txtKdBeli.getText());
            pStatement.setString(4, txtKdSupplier.getText());
            //String kdKota = Integer.toString(cbTipeHarga.getSelectedIndex());
            //pStatement.setString(3, kdKota);
            //pStatement.setInt(4, tHarga);
            pStatement.setString(5, "admin");

            int intTambah = pStatement.executeUpdate();
            if (intTambah>0){
                JOptionPane.showMessageDialog(this,
                        "Data berhasil disimpan", "Informasi",
                        JOptionPane.INFORMATION_MESSAGE);

                //insert detail
                insertDataReturDetail();
            }else{
                //JOptionPane.showMessageDialog(this,
                //        "Penambahan gagal", "Informasi",
                //        JOptionPane.INFORMATION_MESSAGE);
            }
            pStatement.close();
        }
        catch(SQLException e){
            System.out.println("koneksi gagal " + e.toString());
        }

    }
    private void insertDataReturDetail(){
        // panggil method koneksi
        //java.sql.Connection conn = new DBConnection().connect();

        java.sql.PreparedStatement pStatement = null;
        String sql = "INSERT INTO tbeli_retur_detail " +
                "(idReturBeli, kdBrg, bal, slop, bks, ditangani) " +
                "VALUES (?,?, ?,?,?, '0')";

        int rows = tbDetailRetur.getRowCount();
        for (int i=0; i< rows; i++) {
            try {
                pStatement = conn.prepareStatement(sql);
                //iHarga = iHarga + Integer.parseInt(tbTransaksi.getValueAt(i, 5).toString());
                pStatement.setString(1, txtKdReturBeli.getText());
                pStatement.setString(2, tbDetailRetur.getValueAt(i, 0).toString());//kdbrg
                
                //bal
                pStatement.setString(3, tbDetailRetur.getValueAt(i, 2).toString());//bal
                //slop
                pStatement.setString(4, tbDetailRetur.getValueAt(i, 3).toString());//slop
                //bks
                pStatement.setString(5, tbDetailRetur.getValueAt(i, 4).toString());//bks
                
                int intTambah = pStatement.executeUpdate();
                if (intTambah>0){
                    //JOptionPane.showMessageDialog(this,
                    //        "Penambahan data sukses", "Informasi",
                    //        JOptionPane.INFORMATION_MESSAGE);
                }else{
                    JOptionPane.showMessageDialog(this,
                            "Penambahan detail gagal", "Informasi",
                            JOptionPane.INFORMATION_MESSAGE);
                }
                pStatement.close();

            }catch(SQLException e){
                System.out.println("koneksi gagal " + e.toString());
            }
        }

        //updateDataBrg();
        kosongkanNew();
    }
}
